package com.emergency.order.controller;

import com.emergency.base.domain.Order;
import com.emergency.base.domain.Scenar;
import com.emergency.base.domain.Woven;
import com.emergency.order.service.DocService;
import com.emergency.common.entity.Result;
import com.emergency.common.entity.StatusCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by lijie on 2019/10/17.
 * 文书指挥类
 */
@RestController
@RequestMapping("/doc")
@Api(value="文书指挥类",description = "用于下达命令")
public class DocController {

    @Autowired
    private DocService docService;

    @ApiOperation(value = "想定文件发送接口" ,  notes="初始态势想定完成后发送各队长")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "scenar", value = "想定文件", required = true, paramType = "query"),
            @ApiImplicitParam(name = "wovens", value = "救援分队", required = true, paramType = "query")
    })
    @RequestMapping(value = "send/initial",method = RequestMethod.POST)
    public Result sendInitial(Scenar scenar, List<Woven> wovens){
        boolean flag = docService.sendInitial(scenar,wovens);
        return new Result(flag, StatusCode.OK,  "发送成功", "");
    }

    @ApiOperation(value = "分队命令发送接口" ,  notes="发送命令")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "order", value = "命令", required = true, paramType = "query", dataType = "Object")
    })
    @RequestMapping(value = "send",method = RequestMethod.POST)
    public Result send(Order order){
        boolean flag = docService.sendCommand(order);
        return new Result(flag, StatusCode.OK,  "发送成功", "");
    }
}
